# $Id$
# Maintainer: Eric Bélanger <eric@archlinux.org>

pkgname=portmidi
pkgver=217
pkgrel=6
pkgdesc="Platform independent library for real-time MIDI input/output"
arch=('x86_64')
url="http://portmedia.sourceforge.net/"
license=('GPL')
depends=('alsa-lib')
makedepends=('cmake' 'jdk8-openjdk')
optdepends=('java-runtime: for using pmdefaults')
options=('!makeflags')
source=(http://downloads.sourceforge.net/project/portmedia/${pkgname}/${pkgver}/${pkgname}-src-${pkgver}.zip
        portmidi-217-build-fix.patch)
sha1sums=('f45bf4e247c0d7617deacd6a65d23d9fddae6117'
          'a89b80531ccc823ba267aaf21920e59deec80e99')

prepare() {
  cd ${pkgname}
  sed -i "s#/usr/local#/usr#" */CMakeLists.txt pm_python/setup.py
  mkdir -p pm_java/Release

  # build fix for "pm_java/CMakeLists.txt" (fixes FS#27118)
  patch -p1 -i "${srcdir}/portmidi-217-build-fix.patch" 
}

build() {
  cd ${pkgname}
  cmake . -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=Release \
    -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=Release \
    -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=Release
  make
}

package() {
  cd ${pkgname}
  make DESTDIR="${pkgdir}" install

  # Fix missing symlink for libporttime.so (FS#21528).
  ln -s libportmidi.so "${pkgdir}/usr/lib/libporttime.so"
}
